package com.mes.basicdata.dao;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.mes.basicdata.dao.iface.IOperationDao;
import com.mes.basicdata.dao.iface.IOperationDeviceDao;
import com.mes.basicdata.domain.Operation;
import com.mes.basicdata.domain.OperationDevice;
import com.mes.basicdata.domain.OperationPart;
import com.mes.basicdata.domain.WorkCenter;
import com.mes.common.dao.BasicDao;

@Repository
public class OperationDeviceDao extends BasicDao<OperationDevice> implements IOperationDeviceDao{
	@Autowired
	private IOperationDao operationDao;
	
	@Override
	public List<OperationDevice> getOperationDeviceListByOperationUid(String operationUid) throws Exception {
		Operation operation = operationDao.getById(operationUid);
		Set<OperationDevice> operationDevices = operation.getOperationDevices();
		List<OperationDevice> list = new ArrayList<OperationDevice>();
		for (OperationDevice od : operationDevices) {
			list.add(od);
		}
		return list;
	}

	@Override
	public List<WorkCenter> getWorkCenterByOperationUid(String operationUid) throws Exception {
		Operation operation = operationDao.getById(operationUid);
		WorkCenter workCenter = operation.getWorkCenter();
		List<WorkCenter> list = new ArrayList<WorkCenter>();
		list.add(workCenter);
		return list;
	}
}